#ifndef ROOMGATEWAY_COMMAND_IN_H_
#define ROOMGATEWAY_COMMAND_IN_H_
#include "command.h"

#pragma pack(1)
namespace Cmd
{
        namespace RoomGateway
        {
                //  cmd declaration
                enum {
                        CMDIN_LOGIN             = 0x0011,       // 登录RoomGatewayServer验证指令
                        CMDIN_FORWARD           = 0x0012,	// 转发的指令
                };
                enum { //CMDIN_LOGIN
                        SCMDIN_LOGIN                            = 0x0001,       // 请求登录RoomGatewayServer
                        SCMDIN_LOGIN_RESPONCE                   = 0x0002,       // 登录RoomGatewayServer返回
                };
                //RoomGatewayServer转发的指令均为 namespace为Cmd::Room 的指令
                enum { //CMDIN_FORWARD 
                        //-> RoomGatewayServer -> RoomServer
                        SCMDIN_FORWARD_TO_ROOMSERVER_BY_ROOMID  = 0x0001,       // 转发指令到room所在的roomserver
                        SCMDIN_FORWARD_TO_ROOMSERVER_BY_SERVERID        = 0x0002,       // 转发指令到指定的roomserver
                        SCMDIN_FORWARD_TO_ANYONE_ROOMSERVER     = 0x0003,	// 转发指令到任意一台roomserver
                        SCMDIN_FORWARD_TO_ALL_ROOMSERVER        = 0x0004,	// 转发指令到所有roomserver

                        //RoomServer -> RoomGatewayServer -> other server
                        SCMDIN_FORWARD_ROOMCMD_TO_OTHERSERVER   = 0x0005,
                };

                //	cmd definition
                struct stLoginCmd:t_NullCmd
                {
                        stLoginCmd():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN)
                        {
                                dest_type_ = ROOMGATEWAYSERVER;
                                server_type_ = 0;
                                server_id_ = 0;
                        }
                        WORD dest_type_;
                        WORD server_type_;
                        DWORD server_id_;
                };
                struct stLoginResponce:t_NullCmd
                {
                        stLoginResponce():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RESPONCE)
                        {
                        }
                };

                // forward cmd
                struct stForwardToRoomServerByRoomID:
                        t_NullCmd
                {
                        stForwardToRoomServerByRoomID():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_ROOMSERVER_BY_ROOMID)
                        {
                                room_id_ = 0;
                                size_ = 0;
                        }
                        DWORD room_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardToRoomServerByServerID:
                        t_NullCmd
                {
                        stForwardToRoomServerByServerID():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_ROOMSERVER_BY_SERVERID)
                        {
                                server_id_ = 0;
                                size_ = 0;
                        }
                        WORD server_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardToAnyOneRoomServer:
                        t_NullCmd
                {
                        stForwardToAnyOneRoomServer():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_ANYONE_ROOMSERVER)
                        {
                                size_ = 0;
                        }
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardToAllRoomServer:
                        t_NullCmd
                {
                        stForwardToAllRoomServer():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_TO_ALL_ROOMSERVER)
                        {
                                size_ = 0;
                        }
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardRoomCmdToOtherServer:
                        t_NullCmd
                {
                        stForwardRoomCmdToOtherServer():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_ROOMCMD_TO_OTHERSERVER)
                        {
                                room_server_id_ = 0;
                                size_ = 0;
                        }
                        WORD room_server_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };

        }; //namespace RoomGateway
}; //namespace Cmd
#pragma pack() //pack(1)

#endif //ROOMGATEWAY_COMMAND_H_
